package com.ahao.aggregation;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.KeyEvent;

import com.ahao.abstraction.BaseChannel;
import com.ahao.abstraction.ILifeCycle;
import com.ahao.abstraction.PayParams;
import com.ahao.abstraction.ISDKListener;
import com.ahao.abstraction.RoleInfoParams;
import com.ahao.aggregation.utils.SimpleHttpGetRequest;

import org.json.JSONObject;

public class AHAOSDK extends BaseChannel implements ILifeCycle {
    private final int WHAT_LOGIN_CALLBACK = 1;
    private final int WHAT_PAY_CALLBACK = 2;

    private Handler handler = new Handler(new Handler.Callback() {
        @Override
        public boolean handleMessage(Message message) {
            switch (message.what) {
                case WHAT_LOGIN_CALLBACK:
                    mISDKListener.onLoginResult(message.arg1, message.arg2);
                    break;
                case WHAT_PAY_CALLBACK:
                    mISDKListener.onPayResult(message.arg1, message.obj.toString());
                    break;
                default:
                    throw new IllegalStateException("Unexpected value: " + message.what);
            }
            return false;
        }
    });
    private ISDKListener mISDKListener;

    @Override
    public void login(Context context) {
        super.login(context);
        AHAOUiManager.getInstance().showLogin(context);
    }

    @Override
    public void pay(Context context, PayParams payParams) {
        super.pay(context, payParams);
        AHAOUiManager.getInstance().showPay(context, payParams);
    }

    @Override
    public void init(Activity activity, ISDKListener isdkListener) {
        super.init(activity, isdkListener);
        mISDKListener = isdkListener;
    }

    @Override
    public void uploadRoleInfo(Context context, RoleInfoParams roleInfoParams) {

    }

    @Override
    public ILifeCycle getLifeCycle() {
        return this;
    }

    @Override
    public void onStart() {

    }

    @Override
    public void onPause() {

    }

    @Override
    public void onResume() {

    }

    @Override
    public void onNewIntent(Intent intent) {

    }

    @Override
    public void onStop() {

    }

    @Override
    public void onDestroy() {

    }

    @Override
    public void onRestart() {

    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {

    }

    @Override
    public void onSaveInstanceState(Bundle outState) {

    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {

    }

    @Override
    public void onBackPressed() {

    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        return false;
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {

    }
}
